<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    
  </style>
</head>
<body>
  <a href="http://www.baidu.com" class="baidulink">12312</a>
</body>
<script>

  var baidulink = document.querySelector(".baidulink")

  baidulink.onclick = function(eve){
    var e = eve || window.event;
    stopDefault(e);
  }

  document.oncontextmenu = function(eve){
    var e = eve || window.event;

    // e.preventDefault();
    // e.returnValue = false;

    stopDefault(e);

    console.log(1);

    // return false;
  }


  function stopDefault(e){
    if(e.preventDefault){
      e.preventDefault()
    }else{
      e.returnValue = false;
    }
  }
  
</script>
</html>